package common.server.feign;

import feign.Response;
import feign.codec.ErrorDecoder;
import org.slf4j.LoggerFactory;

import static feign.FeignException.errorStatus;

/**
 * @Title: DefaultErrorDecoder
 * @ProjectName com-bigwavn-group
 * @Description: feign 默认系统异常
 * @author: wangweitao 1749343503@qq.com
 * @date: 2019/6/4 16:11
 * @version: V1.0.0
 */
public class DefaultErrorDecoder implements ErrorDecoder {

    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(DefaultErrorDecoder.class);
    @Override
    public Exception decode(String methodKey, Response response) {
        logger.error("FeignClient - Http-Error:[url:{},status:{},reason:{}]",response.request().url(), response.status(), response.reason());
        return errorStatus(methodKey, response);
    }
}
